///////////////////////////////////////////////////////////
///////////////// Have an itch? Scratch it! ///////////////
///////////////////////// SCRATCH /////////////////////////
/////////////////////  A MUD  Server   ////////////////////
///////////////////// By: Jared Devall ////////////////////
/////////////////////      Thanks:     ////////////////////
/////////////////////  DIKU/Merc/ROM   ////////////////////
///////////////////// Aetas/Deus Gang  ////////////////////
/////////////////////       Beej       ////////////////////
///////////////////////////////////////////////////////////

#ifndef __TIMER_H
#define __TIMER_H

#include "definitions.h"
#include <ctime>
#include <string>


class Timer {
	public:
		std::string 		_name;
		bool				_enabled;
		unsigned long int	_interval;
		time_t				_when;

	public:
		Timer();
		virtual ~Timer() { }

		void		setName( std::string );
		std::string getName();
		void		setEnabled( bool );
		bool		getEnabled();
		void		setWhen( time_t );
		time_t		getWhen();

		void			Reset();
		void			Reset( unsigned long int );
		void			Reset( unsigned long int, unsigned long int );
		bool			Fire();
		virtual bool	Execute() = 0;
};

class Tick: public Timer {
	public:
		Tick();
		~Tick();

		bool Execute();
};

class Autosave: public Timer {
	public:
		Autosave();
		~Autosave();

		bool Execute();
};

class Autoreboot: public Timer {
	private:
		int		_stage;
		unsigned long int	_fiveMinuteWarning;
		unsigned long int	_thirtySecondWarning;
		unsigned long int	_countdownThree;
		unsigned long int	_countdownTwo;
		unsigned long int	_countdownOne;
		unsigned long int	_countdownOver;

		void setWarningTimers();

	public:
		Autoreboot();
		~Autoreboot();

		bool Execute();
};

class Autobackup: public Timer {
	public:
		Autobackup();
		~Autobackup();

		bool Execute();
};



#endif // __TIMER_H
